package com.houweishi.module.clocking.task;


import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.module.clocking.service.IBizClockingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;

/**
 * 员工打卡定时任务
 *
 * @author zhaoxi
 * @date 2023-03-03
 */
@Component("clockTask")
public class ClockTask {
    private static final Logger LOGGER = LoggerFactory.getLogger(ClockTask.class);
    @Resource
    private IBizClockingService bizClockingService;

    @Scheduled(cron = "0 0 0 * * ? ")
    @GetMapping("/dealAttendance")
    public AjaxResult dealAttendance() {
        try {
            LOGGER.info("员工打卡定时任务开始");
            return bizClockingService.dealAttendance();
        } catch (Exception e) {
            LOGGER.error("员工打卡定时任务处理失败",e);
            return AjaxResult.error();
        }
    }
}
